package com.fy56.platform.goodsTracking.car.service.impl;

import com.dexcoder.dal.JdbcDao;
import com.fy56.platform.goodsTracking.car.mode.Document;
import com.fy56.platform.goodsTracking.car.service.DocumentService;
import com.fy56.platform.goodsTracking.model.GoodstrackedRecordPublic;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by XTK on 2017-04-26.
 */
@Repository
public class DocumentServerImpl implements DocumentService {

    @Autowired
    private JdbcDao jdbcDao_GoodsTracked;
    static Logger log = Logger.getLogger(DocumentServerImpl.class);

    @Override
    public List<Document> list(String organizationcode, String beginTime, String endTime, String upstreamCompanyArray) {
        String sql = "select aa.ConsignmentBillMasterId,aa.ConsigneeCompanyCode,aa.ConsignorCompanyCode,aa.ConsignmentBillNumber\n" +
                ",aa.GoodsNumber,aa.ManualNumber,bb.info,bb.CreateCompanyName,convert(varchar,bb.DataType) DataType,convert(varchar,bb.TypeNum) TypeNum, replace(replace(replace(convert(varchar,bb.SysTime,120),'-',''),' ',''),':','') SysTime,bb.Createoperator " +
                " from GoodsTracked_Record_public bb  WITH(NOLOCK) \n" +
                " left join  GoodsTracked_Record_top_public aa  WITH(NOLOCK) \n" +
                " on aa.ConsignmentBillMasterId=bb.ConsignmentBillMasterId\n" +
                " where aa.organizationcode='" + organizationcode + "' and aa.ConsignorCompanyCode  in (" + upstreamCompanyArray + ")" +
                " and  bb.Systime<='" + endTime + "'" +
                " and  bb.Systime>='" + beginTime + "'" +
                " order by bb.systime";
        //System.out.print(sql);
        log.info(sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, Document.class);

    }
}
